package com.block.common.enums;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BaseTypeInfoEnum {

    public static void main(String[] args) {

        System.out.println(JSON.toJSONString(Zhima.getDataMap()));
    }

    public static JSONObject resultData = new JSONObject();

    public static List<BaseTypeInfo> multDataList = new ArrayList<>();
    public static List<BaseTypeInfo> singleDataList = new ArrayList<>();

    static {
        //贷款金额
        multDataList.add(
                BaseTypeInfo.build(LoanAmount.baseName, LoanAmount.baseValue, LoanAmount.getDataMap())
        );
        //贷款时间
        multDataList.add(
                BaseTypeInfo.build(LoanTime.baseName, LoanTime.baseValue, LoanTime.getDataMap())
        );
        //芝麻分数
        multDataList.add(
                BaseTypeInfo.build(Zhima.baseName, Zhima.baseValue, Zhima.getDataMap())
        );

        // 白条
        multDataList.add(
                BaseTypeInfo.build(Baitiao.baseName, Baitiao.baseValue, Baitiao.getDataMap())
        );

        // 花呗
        multDataList.add(
                BaseTypeInfo.build(Huabei.baseName, Huabei.baseValue, Huabei.getDataMap())
        );
        // 学历
        multDataList.add(
                BaseTypeInfo.build(XueLi.baseName, XueLi.baseValue, XueLi.getDataMap())
        );

        //公积金
        singleDataList.add(
                BaseTypeInfo.build(Gjj.baseName, Gjj.baseValue)
        );
        //收入
        singleDataList.add(
                BaseTypeInfo.build(Shouru.baseName, Shouru.baseValue, Shouru.getDataMap())
        );

        //房产
        singleDataList.add(
                BaseTypeInfo.build(House.baseName, House.baseValue)
        );


        //车产
        singleDataList.add(
                BaseTypeInfo.build(Car.baseName, Car.baseValue)
        );
        //学历
        singleDataList.add(
                BaseTypeInfo.build(Car.baseName, Car.baseValue)
        );


        //社保
        singleDataList.add(
                BaseTypeInfo.build(Shebao.baseName, Shebao.baseValue)
        );

        //工作
        singleDataList.add(
                BaseTypeInfo.build(Gongzuo.baseName, Gongzuo.baseValue)
        );

        //保险
        singleDataList.add(
                BaseTypeInfo.build(Baoxian.baseName, Baoxian.baseValue)
        );

        // 有无逾期
        singleDataList.add(
                BaseTypeInfo.build(Yuqi.baseName, Yuqi.baseValue)
        );
        // 有无逾期
        singleDataList.add(
                BaseTypeInfo.build(Yongtu.baseName, Yongtu.baseValue)
        );

        resultData.put("multDataList", multDataList);
        resultData.put("singleDataList", singleDataList);

    }


    @Data
    public static class BaseTypeInfo{
        private  String name;
        private  String value;
        private  List<Map<String, String>> itemList;

        public static BaseTypeInfo build(String name, String value, List<Map<String, String>> itemList){
            BaseTypeInfo baseTypeInfo = new BaseTypeInfo();
            baseTypeInfo.setName(name);
            baseTypeInfo.setValue(value);
            baseTypeInfo.setItemList(itemList);
            return baseTypeInfo;
        }

        public static BaseTypeInfo build(String name, String value){
            BaseTypeInfo baseTypeInfo = new BaseTypeInfo();
            baseTypeInfo.setName(name);
            baseTypeInfo.setValue(value);
            return baseTypeInfo;
        }
    }

    @Getter
    public enum LoanAmount{

        la001( "1-3万", "la001", new BigDecimal("30000")),
        la002( "3-5万", "la002", new BigDecimal("50000")),
        la003( "5-10万", "la003", new BigDecimal("100000")),
        la004( "10-20万", "la004", new BigDecimal("200000")),
        la005( "20万及以上", "la005", new BigDecimal("250000")),
        ;

        public static String baseName = "贷款额度";
        public static String baseValue = "loanAmount";

        String value;
        String name;
        BigDecimal amount;

        LoanAmount(String name, String value, BigDecimal amount){
            this.value = value;
            this.name = name;
            this.amount = amount;
        }

        public static String getNameByValue(String value){
            for (LoanAmount loanAmount: values()){
                if (StrUtil.equals(value, loanAmount.getValue())){
                    return loanAmount.getName();
                }
            }
            return null;
        }

        public static LoanAmount getEntryByValue(String value){
            for (LoanAmount loanAmount: values()){
                if (StrUtil.equals(value, loanAmount.getValue())){
                    return loanAmount;
                }
            }
            return la001;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (LoanAmount item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum LoanTime{

        lt001( "1-3个月", "lt001",true),
        lt002( "3-6个月", "lt002", true),
        lt003( "6-12个月", "lt003", true),
        lt004( "12个月以上", "lt004", true),
        ;

        public static String baseName = "贷款时间";
        public static String baseValue = "loanTime";

        String value;
        String name;
        boolean showFlag;

        LoanTime(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (LoanTime item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (LoanTime item: values()){
                if (!item.showFlag)continue;
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Huabei{

        hb001( "无花呗", "hb001", false),
        hb002( "1-5万", "hb002", true),
        hb003( "5-10万", "hb003", true),
        hb004( "10-20万", "hb004", true),
        hb005( "20万以上", "hb005", true),
        ;

        public static String baseName = "有花呗";
        public static String baseValue = "huabei";

        String value;
        String name;
        boolean showFlag;

        Huabei(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (Huabei item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Huabei item: values()){
                if (!item.showFlag)continue;
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Baitiao{

        bt001( "无白条", "bt001",false),
        bt002( "1-5万", "bt002",true),
        bt003( "5-10万", "bt003", true),
        bt004( "10-20万", "bt004", true),
        bt005( "20万以上", "bt005", true),
        ;

        public static String baseName = "有白条";
        public static String baseValue = "baitiao";

        String value;
        String name;
        boolean showFlag;

        Baitiao(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (Baitiao item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Baitiao item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Zhima{

        zm001( "无芝麻分", "zm001",false),
        zm002( "1-599分", "zm002",true),
        zm003( "600-649分", "zm003", true),
        zm004( "650-699分", "zm004", true),
        zm005( "700分以上", "zm005", true),
                ;

        public static String baseName = "芝麻分数";
        public static String baseValue = "zhima";

        String value;
        String name;
        boolean showFlag;


        Zhima(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static String getNameByValue(String value){
            for (Zhima zhimaScore: values()){
                if (StrUtil.equals(value, zhimaScore.getValue())){
                    return zhimaScore.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Zhima item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum Yuqi{

        yq001("无逾期", "yq001"),
        yq002("0-3个月", "yq002"),
        yq003("3-6个月", "yq003"),
        yq004("6-12个月", "yq004"),
        yq005("12个月以上", "yq005"),
        ;

        public static String baseName = "有逾期";
        public static String baseValue = "yuqi";

        String value;
        String name;


        Yuqi(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Yuqi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Yuqi item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum Gjj{

        gjj001("无公积金", "gjj001"),
        gjj002("0-6个月", "gjj002"),
        gjj003("6个月以上", "gjj003"),
        ;

        public static String baseName = "有公积金";
        public static String baseValue = "gjj";

        String value;
        String name;
        

        Gjj(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Gjj gjj: values()){
                if (StrUtil.equals(value, gjj.getValue())){
                    return gjj.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Gjj item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum Shouru{

        sr001("1-5000元", "sr001"),
        sr002("5000-10000元", "sr002"),
        sr003("10000-20000元", "sr003"),
        sr004("20000元以上", "sr004"),
        ;

        public static String baseName = "收入";
        public static String baseValue = "shouru";

        String value;
        String name;


        Shouru(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (Shouru salary: values()){
                if (StrUtil.equals(value, salary.getValue())){
                    return salary.getName();
                }
            }
            return null;
        }


        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Shouru item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum House{

        hu001( "无房", "hu001"),
        hu002( "自建房", "hu002"),
        hu003( "按揭房可抵押", "hu003"),
        hu004( "按揭不可抵押", "hu004"),
        ;

        public static String baseName = "有房";
        public static String baseValue = "house";

        String value;
        String name;
        

        House(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (House house: values()){
                if (StrUtil.equals(value, house.getValue())){
                    return house.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (House item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Yongtu{

        yt001("消费", "yt001"),
        yt002("买房", "yt002"),
        yt003("买车", "yt003"),
        yt004("装修", "yt004"),
        yt005("教育", "yt005"),
        yt006("周转", "yt006"),
        yt007("其他", "yt007"),
        ;
        public static String baseName = "用途";
        public static String baseValue = "Yongtu";


        String value;
        String name;

        Yongtu(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (Yongtu job: values()){
                if (StrUtil.equals(value, job.getValue())){
                    return job.getName();
                }
            }
            return null;
        }



        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Yongtu item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum Gongzuo{

        gz001("上班族", "gz001"),
        gz002("企业主", "gz002"),
        gz003("自由职业", "gz003"),
        gz004("事业单位", "gz004"),
        gz005("其他", "gz005"),
        ;

        public static String baseName = "工作";
        public static String baseValue = "gongzuo";


        String value;
        String name;


        Gongzuo(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (Gongzuo job: values()){
                if (StrUtil.equals(value, job.getValue())){
                    return job.getName();
                }
            }
            return null;
        }



        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Gongzuo item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Car{

        car001("无车", "car001"),
        car002("有车可抵押", "car002"),
        car003("有车不可抵押", "car003"),
        ;

        public static String baseName = "有车";
        public static String baseValue = "car";

        String value;
        String name;
        

        Car(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Car car: values()){
                if (StrUtil.equals(value, car.getValue())){
                    return car.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Car item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Baoxian{

        bx001( "无保险", "bx001"),
        bx002( "0-6个月", "bx002"),
        bx003( "6个月以上", "bx003"),
        ;

        public static String baseName = "有保险";
        public static String baseValue = "baoxian";

        String value;
        String name;



        Baoxian(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (Baoxian insurance: values()){
                if (StrUtil.equals(value, insurance.getValue())){
                    return insurance.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Baoxian item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Shebao{

        sb001( "无社保", "sb001"),
        sb002( "0-6个月", "sb002"),
        sb003( "6个月以上", "sb003"),
        ;

        public static String baseName = "有社保";
        public static String baseValue = "shebao";

        String value;
        String name;


        Shebao(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Shebao item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Shebao item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }



    @Getter
    public enum XueLi{

        xl001("无学历", "xl001", true),
        xl002("中专或以下", "xl002", true),
        xl003("大专", "xl003", true),
        xl004("本科", "xl004", true),
        xl005("研究生及以上", "xl005", true),
        ;

        String value;
        String name;
        boolean showFlag;

        public static String baseName = "学历";
        public static String baseValue = "xueli";

        XueLi(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static XueLi getEntryByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return xl002;
        }

        public static String getNameByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (XueLi item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum XinYongKa{

        xyk001("无信用卡", "xyk001", true),
        xyk002("1-5万", "xyk002", true),
        xyk003("5-10万", "xyk002", true),
        xyk004("10-20万", "xyk002", true),
        xyk005("20万以上", "xyk002", true),
        ;

        String value;
        String name;
        boolean showFlag;

        public static String baseName = "信用卡";
        public static String baseValue = "xinyongka";

        XinYongKa(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static XinYongKa getEntryByValue(String value){
            for (XinYongKa item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return xyk001;
        }

        public static String getNameByValue(String value){
            for (XinYongKa item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (XinYongKa item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum WeiLi{

        wl001("0-3万", "wl001", true),
        ;

        String value;
        String name;
        boolean showFlag;

        public static String baseName = "微粒贷";
        public static String baseValue = "weili";

        WeiLi(String name, String value, boolean showFlag){
            this.value = value;
            this.name = name;
            this.showFlag = showFlag;
        }

        public static WeiLi getEntryByValue(String value){
            for (WeiLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return wl001;
        }

        public static String getNameByValue(String value){
            for (WeiLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (WeiLi item: values()){
                if (!item.showFlag)continue;

                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }
}
